home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Freeware 2002 November
/
SGI Freeware 2002 November - Disc 2.iso
/
dist
/
fw_ircd-hybrid.idb
/
etc
/
init.d
/
ircd.z
/
ircd
Wrap
Text File
|
2001-10-09
|
3KB
|
131 lines
#!/bin/sh
# Start Internet Relay Chat Daemon
# --srosa/SGI
# "$revision: 2.0 $"
IS_ON="/sbin/chkconfig"
UID="/usr/bin/id"
LS="/usr/bin/ls"
NAWK="/bin/nawk"
GREP="/bin/grep"
if [ ! -x $IS_ON -o ! -x $UID -o ! -x $LS -o ! -x $GREP ]; then
echo "ERROR: some tools needed by the ircd init script are not available. aborted."
exit 1
fi
if $IS_ON verbose ; then
ECHO=echo
else
ECHO=:
fi
CONFIG=/etc/config
BINDIR=/usr/freeware/bin
LIBDIR=/usr/freeware/lib/ircd
HYBDIR=${LIBDIR}/hybserv
Start_Server() {
if $IS_ON ircd; then
# Check out that a specific user has been created. The daemon MUST NOT
# run as root.
if ! $UID ircadmin > /dev/null 2>&1; then
$ECHO "\nERROR: user ircadmin does not exist. Cannot start ircd server."
exit 0
fi
# Check out that ownership/permissions are ok, or try to fix it. swmgr
# installs the package as root by default.
if ! $LS -l ${BINDIR}/ircd | $GREP -q -e "rws.*ircadmin" > /dev/null 2>&1; then
$ECHO "\nERROR: ircd server files MUST belong to user ircadmin. Trying to fix it."
if ! ${LIBDIR}/fixperms > /dev/null 2>&1; then
$ECHO "\nERROR: chown failed. Fix it manually. Cannot start ircd server."
exit 0
fi
fi
# If everything seems right, start the daemon
$ECHO "Starting Internet Relay Chat daemon:\c"
${BINDIR}/ircd `cat ${CONFIG}/ircd.options 2> /dev/null`
$ECHO " ircd\c"
# If it is installed and enabled, wait a bit for the irc daemon to
# come up, then start the HybServ IRC Services daemon (NickServ, etc)
if [ -d $HYBDIR -a -x ${HYBDIR}/hybserv ]; then
if $IS_ON hybserv; then
# Check out that ownership/permissions are ok there as well, in
# case hybserv has been installed after ircd's first run
if ! $LS -l ${HYBDIR}/hybserv | $GREP -q -e "rws.*ircadmin" > /dev/null 2>&1; then
$ECHO "\nERROR: hybserv files MUST belong to user ircadmin. Trying to fix it."
if ! ${LIBDIR}/fixperms > /dev/null 2>&1; then
$ECHO "\nERROR: chown failed. Fix it manually. Cannot start hybserv services."
exit 0
fi
fi
# If everything seems right, start the daemon
sleep 10
su ircadmin -c "${HYBDIR}/hybserv" > /dev/null 2>&1
$ECHO " hybserv\c"
fi
fi
# if the autostart file for bots is there, launch all bots in it
if [ -x $NAWK -a -r ${CONFIG}/ircdbots.config ]; then
su ircadmin -c "$NAWK -f ${CONFIG}/ircdbots.nawk ${CONFIG}/ircdbots.config"
fi
$ECHO "."
exit 0
fi
}
Stop_Server() {
$ECHO "Shutting down Internet Relay Chat daemon."
if [ -x $NAWK -a -r ${LIBDIR}/ircdbots.pid ]; then
$NAWK -f ${CONFIG}/ircdbots.nawk ${LIBDIR}/ircdbots.pid
fi
if [ -r ${HYBDIR}/hybserv.pid ]; then
kill -TERM `head -1 ${HYBDIR}/hybserv.pid` > /dev/null 2>&1
rm ${HYBDIR}/hybserv.pid
fi
sleep 5
if [ -r ${LIBDIR}/ircd.pid ]; then
kill -TERM `head -1 ${LIBDIR}/ircd.pid` > /dev/null 2>&1
rm ${LIBDIR}/ircd.pid
fi
}
case "$1" in
'start')
Start_Server
;;
'stop')
Stop_Server
;;
'restart')
Stop_Server
Start_Server
;;
*)
echo "usage: /etc/init.d/ircd {start|stop|restart}"
;;
esac
exit 0